<?php
// +----------------------------------------------------------------------
// | 有小象汇 自研正版源码 赋能开发者
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 http://www.uxphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 有小象汇并不是自由软件，未经许可不能去掉有小象汇相关版权
// +----------------------------------------------------------------------
// | Author:  有小象汇
// +----------------------------------------------------------------------

namespace app\dao\car;


use app\dao\BaseDao;
use app\model\car\BaseSendFee;

/**
 * Class BaseSendFeeDao
 * @package app\dao\shendeng
 */
class BaseSendFeeDao extends BaseDao
{
    protected function setModel(): string
    {
        return BaseSendFee::class;
    }

    /**
     * 列表
     * @param array $where
     * @param int $page
     * @param int $limit
     * @return array
     */
    public function getList(array $where, int $page,int $limit){
        $model = $this->getModel()->alias('f')->where('f.is_del','=',0);
        $model = $model->field('f.*,p.title');
        $model = $model->join('base_place p','f.store_id=p.id','left');
        $model = $this->setSearch($model,$where);
        $list = $model->order('f.id desc')->page($page,$limit)->select()->toArray();
        $count = $model->count();
        return compact('list','count');
    }

    /**
     * 搜索条件
     * @param $model
     * @param $where
     * @return mixed
     */
    public function setSearch($model,$where){
        if(isset($where['store_id'])&&$where['store_id']){
            $model->where('f.store_id','=',$where['store_id']);
        }
        return $model;
    }
}
